โ– humdrum codex / glint v1.0.2
license AGPL-3.0
2.2 KB raw
id
TASK-018
title
Minimal Alabaster syntax highlighting for code files
status
๐ŸŸฆ Backlog
assignee
created_date
2026-06-29 16:44
labels
feature, release-2
dependencies
priority
medium
ordinal
18000

Description

Makes glint usable as a quick-edit editor for code (not just markdown) so it can reasonably be set as $EDITOR. Alabaster philosophy: color only a few token types, leave the rest base.

Three pieces:

  1. File-type routing: the editor selects a scanner by the file's extension โ€” .md/.markdown/.txt/none -> the existing markdown scanner; known code extensions (.go .py .js .ts .rs .c .h .java .rb .sh .lua .toml .yaml .json โ€ฆ) -> a code scanner. Add editor.SetLanguage/SetScanner; app sets it in Load() from filepath.Ext.
  2. Code scanner via chroma (already a transitive dep through glamour โ€” promote to direct). Use chroma's lexer-by-filename to tokenize, then map ONLY: String* -> string color (reuse Code, or a new String role); Comment* -> Comment (visible); Number/Literal -> Accent; Keyword/Name/Operator -> base Text; Punctuation -> Muted. Everything else base. Split the chroma token stream into per-line []Span; the concatenated span text must equal the raw line (markup-visible / display-only invariant, same as the markdown scanner). Handle multi-line tokens (block comments, multi-line strings).
  3. Theme: reuse Code/Comment/Accent/Muted; optionally add a dedicated String role if strings should differ from inline-code green.

Keep it minimal and calm (Alabaster), not a full IDE theme. Not the main code editor โ€” just 'open, read okay, small change, save'. Verify cursor/selection/wrap still work over code (tabs/CJK width is TASK-005).

Acceptance Criteria